﻿
#ifndef __MapViewController__
#define __MapViewController__

#include <iostream>
#include "CrossApp.h"
#include "AmapView.h"

USING_NS_CC;

class MapViewController : public CAViewController, public AmapViewDelegate
{
    
public:

	MapViewController();
    
	virtual ~MapViewController();
    
protected:
    
    void viewDidLoad();
    
    void viewDidUnload();

	virtual void onAmapLoaded();

	virtual void onAmapClicked(double lat, double lng);

	void addMarkerBtClicked(CAControl* ctrl, DPoint point);

	void delMarkerBtClicked(CAControl* ctrl, DPoint point);

	void clearMarkerBtClicked(CAControl* ctrl, DPoint point);

	virtual void onAmapMarkerDragStart(AmapMarker* marker, double lat, double lng);

	virtual void onAmapMarkerDrag(AmapMarker* marker, double lat, double lng);

	virtual void onAmapMarkerDragEnd(AmapMarker* marker, double lat, double lng);

	virtual void onAmapMarkerClick(AmapMarker* marker);

	virtual void onAmapMarkerInfoWindowClick(AmapMarker* marker);
    
    virtual void onAmapLocationEnd(int code, double lat, double lng, const string& formatAddr, const string& province, const string& city, const string& district, const string& street, const string& number, const string& poi, const string& adcode);

private:

	void amaploaded(float t);

	void amapclicked(float t);

	void amapmarkerdragstart(float t);

	void amapmarkerdrag(float t);

	void amapmarkerdragend(float t);

	void amapmarkerclick(float t);

	void amapmarkerinfowindowclick(float t);

private:

	double m_DLat;

	double m_DLng;

	CALabel* m_pLoadedLb;

	CALabel* m_pLatLngLb;
	
	AmapView* amapView;

	AmapMarker* m_pMarker;
};


#endif
